CC = sdcc
MCU = -mpic14
CHIP = -p14F1501
LIB_SRC = $(wildcard src/lib/*.c)
LIB_REL = $(LIB_SRC:.c=.rel)
LIB_HEX = $(LIB_SRC:.c=.rel)
EXE_SRC = $(wildcard src/*.c)
EXE_REL = $(EXE_SRC:.c=.rel)
EXE = $(EXE_SRC:.c=.hex)

all: dist

.PHONY: dist

dist:
	@mkdir -pv build
	sdcc -c -o build/main.rel -I inc src/main.c 
	packihx build/main.ihx > build/main.hex

lcd:
	@mkdir -pv build
	sdcc -o build/ -I inc src/lcd.c 
	packihx build/lcd.ihx > build/lcd.hex

demo: clean
	@mkdir -pv build
	$(CC) -c -o build/ -I inc src/demo.c 
	$(CC) -c -o build/ -I inc src/lib/utils.c 
	$(CC) -o build/demo.hex build/demo.rel build/utils.rel

x:
	@mkdir -pv build
	gcc src/x.c -o build/x
	./build/x


clean:
	@rm -rf build
debug:
	@echo $(LIB_SRC)
	@echo $(LIB_REL)
	@echo $(EXE)